import React, { Component } from 'react'
import './index.css'
export default class Header extends Component {
  sendTitle(e){
    if(e.code !== 'Enter') return 
    let title = e.target.value.trim()
    this.props.addTodo(title)
    e.target.value = ''
  }
  render() {
    
    return (
        <div className="todo-header">
            <input type="text" onKeyUp={
              
              this.sendTitle.bind(this)} placeholder="请输入你的任务名称，按回车键确认"/>
        </div>
    )
  }
}
